package com.fredia.terp.mq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

import com.fredia.terp.config.EmailSenderUtil;
import com.fredia.terp.model.IEmail;

@Component
public class Consumer {
	@Autowired
	private EmailSenderUtil emailSender;

	// 使用JmsListener配置消费者监听的队列，其中text是接收到的消息
	@JmsListener(destination = "email.queue")
//	@SendTo("out.queue")
	public void receiveQueue(IEmail email) {

		emailSender.sender(email.getAddr(), email.getSubject(), email.getContent());

	}
}